//
//  ZZHomeTopicEntity.m
//  QQplayground
//
//  Created by zhangxy on 2018/6/6.
//  Copyright © 2018年 zhang. All rights reserved.
//

#import "ZZHomeTopicEntity.h"

@implementation ZZHomeTopicEntity

- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
    self = [super init];
    if (self) {
        self = [ZZHomeTopicEntity yy_modelWithDictionary:dictionary];
        
//        _user_info = [[User alloc] initWithDictionary:@{}];
        if([[dictionary allKeys] containsObject:@"user_info"]){
            _user_info = [[User alloc] initWithDictionary:dictionary[@"user_info"]];
        }else{
            _user_info = [User new];
        }
        _thread_list = [[NSMutableArray alloc] init];
        NSMutableArray *arr = dictionary[@"thread_list"];
        if(arr){
            for (NSDictionary *item in arr) {
                [_thread_list addObject:[[ZZTopicCommentEntity alloc] initWithDictionary:item]];
            }
        }
        _images = [[NSMutableArray alloc] init];
        NSArray *imgs = dictionary[@"image"];
        if(imgs){
            for (NSDictionary *item in imgs) {
                [_images addObject:[[ImageEntity alloc] initWithDictionary:item]];
            }
        }
        _nav_name = [self getElementTitle:_nav_type];
    }
    return self;
}

-(NSString *) getElementTitle:(NSString *)navType{
    NSArray *aName = [NSArray arrayWithObjects:@"avatar",@"pic",@"sign",@"name",@"group",@"skin",@"show",@"mimi",@"thread",nil];
    
    //比如我们要把@"stormer"作为switch的参数，则取到它在数组中的下标，然后在switch中根据下标来进行处理。
    int index = (int)[aName indexOfObject:navType];
    switch (index){
        case 0:
            return @"头像";
        case 1:
            return @"图片";
        case 2:
            return @"签名";
        case 3:
            return @"网名";
        case 4:
            return @"分组";
        case 5:
            return @"壁纸";
        case 6:
            return @"自拍";
        case 7:
            return @"秘密";
        case 8:
            return @"帖子";
        default:
            return @"图片";
    }
    return @"图片";
}

+ (NSDictionary<NSString *,id> *)modelCustomPropertyMapper
{
    return @{
             @"t_id" : @"id",
             @"nav_type" : @"nav_type",
             @"title":@"title",
             @"cat_id" : @"cat_id",
             @"user_id" : @"user_id",
             @"user_name" : @"user_name",
             @"user_avatar" : @"user_avatar",
             @"nav_name":@"nav_name",
             @"like_count" : @"like_count",
             @"drop_count" : @"drop_count",
             @"fav_count" : @"fav_count",
             @"add_time" : @"add_time",
             @"is_love" : @"is_love",
             @"message_1" : @"message_1",
             @"message_2" : @"message_2",
             @"image_url" : @"image_url",
             @"image_list" : @"image_list",
             @"image_count":@"image_count",
             @"share_url" : @"share_url",
             @"image_extend" : @"image_extend",
             @"thread_count" : @"thread_count",
             @"message_arr_1" :@"message_arr_1",
             @"message_arr_2":@"message_arr_2",
             @"is_like":@"is_like",
             @"is_fav":@"is_fav"
             };
}

@end
